#include "WindowManager.h"

WindowManager::WindowManager(QObject* parent)
    : QObject(parent) {
}

WindowManager::~WindowManager() {
}

void WindowManager::addSubWindow(QString windowName, QWidget* subWindow) {
    if (stackedWidget == nullptr) return;
    auto p = subWindows.find(windowName);
    if (p == subWindows.end()) {
        subWindows[windowName] = subWindow;
    }
    stackedWidget->addWidget(subWindow);
    emit signalAddSubWindow(subWindow);
}

void WindowManager::setCurrentWidget(QWidget* widget) {
    stackedWidget->setCurrentWidget(widget);
}

void WindowManager::delSubWindow(QString windowName) {
    auto p = subWindows.find(windowName);
    if (p != subWindows.end()) {
        subWindows.erase(windowName);
    }
}

void WindowManager::setStackedWidget(QStackedWidget* statckeWidget) {
    this->stackedWidget = statckeWidget;
}

ChatListForm* WindowManager::getChatListForm() {
    return chatListForm;
}

void WindowManager::setChatListForm(ChatListForm* chatListForm) {
    this->chatListForm = chatListForm;
}
